<template>
	<div class="userInfo">
		<dl>
			<dt>会员编号</dt>
			<dd>{{ userInfo.username }}</dd>
		</dl>
		<dl>
			<dt>姓名</dt>
			<dd>{{ userInfo.nickname }}</dd>
		</dl>
		<dl>
			<dt>手机号</dt>
			<dd>{{ userInfo.mobile }}</dd>
		</dl>

		<div class="loginOut" @click='isShow = true'>退出登录</div>
		<confirm theme='android' class="outConfirm" title='确定退出？' @yes='loginOutEv' v-model="isShow"></confirm>
	</div>
</template>

<script>
import { getUserInfo, loginOut } from '../../../config/getData'
import Confirm from '../../component/confirm/confirm'

export default {
	data(){
		return {
			userInfo:{},
			isShow:false
		}
	},
	created(){
		getUserInfo().then( res => {
			this.userInfo = res
		})
	},
	methods:{
		loginOutEv(){
			loginOut().then( res => {
				localStorage.removeItem('userInfo')

				var isShowNot = typeof localStorage.isShowNot == 'string' ? JSON.parse(localStorage.isShowNot) : false
				if(isShowNot){
					isShowNot.look = false
					localStorage.isShowNot = JSON.stringify(isShowNot)
				}

				this.$router.push('/login')
			})
		},
		setCookie(cname, cvalue, exdays) {
			var d = new Date();
			d.setTime(d.getTime() + (exdays*24*60*60*1000));
			var expires = "expires="+d.toUTCString();
			document.cookie = cname + "=" + cvalue + "; " + expires;
		}
	},
	components:{
		Confirm
	}
}
</script>


<style lang="scss" scoped>
.userInfo{
	dl{display: flex;line-height: 45px;background-color: white;padding:0 15px;
		dt{width:80px;}
	}
	dl + dl{border-top:1px solid #f0f0f0;}
	.loginOut{margin:40px 0;width:100%;line-height: 45px;color:#E64340;font-size: 16px;background-color: white;text-align: center;}
}
</style>
